<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> -->
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
    <title>react</title>
</head>

<body>
    <!-- 准备好一个容器 -->
    <div class="test"></div>

    <!-- js按顺序引入 -->
    <!-- 引入react核心库 -->
    <script type="text/javascript" src="../js/react.development.js"></script>

    <!-- 引入react-dom,用于操作dom -->
    <script type="text/javascript" src="../js/react-dom.development.js"></script>

    <!-- 引入babel,用于将jsx转为js -->
    <script type="text/javascript" src="../js/babel.min.js"></script>

    <script type="text/babel">
        // 1.创建类式组件 组件名首字母必须大写
        class Weather extends React.Component{
            state = {
                    isHot:true,
                }
           
            render(){
                const {isHot} = this.state
                return <h1 onClick={this.changeWeather}>今天天气是{isHot ?'炎热' : '凉快'}</h1>
            }
            changeWeather = () =>{
                // 这里的this指向了weather实例
                const isHot = this.state.isHot
                this.setState( {isHot:!isHot})

            }
        }
       
    
      // 2.渲染虚拟Dom 
      ReactDOM.render(<Weather/>, document.querySelector(".test"));

    </script>
</body>
<style>

</style>

</html>